package cn.com.oceansoft.application.web;

import cn.com.oceansoft.framework.kits.ApiResult;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * Created by zhangxh on 2016/9/26.
 */
@ControllerAdvice(basePackages = "cn.com.oceansoft.modules")
@Controller
public class BaseControllerAdvice {
    @ResponseBody
    @ExceptionHandler(value = {RuntimeException.class,Exception.class})
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public ApiResult ex(RuntimeException e){
        e.printStackTrace();
        return new ApiResult(false, HttpStatus.INTERNAL_SERVER_ERROR.value(),"服务器异常",null);
    }
}
